import pandas as pd

wD = pd.read_excel('测风数据2.0（完整）杨明海&焦志雄 .xlsx',parse_dates=['Date & Time Stamp'])

den = 1.041#空气密度

vFreq={'<0.5':0,'1':0,'2':0,'3':0,'4':0,'5':0,'6':0,'7':0,'8':0,'9':0,'10':0,
             '11':0,'12':0,'13':0,'14':0,'15':0,'16':0,'17':0,'18':0,'19':0}
pFreq={'<0.5':0,'1':0,'2':0,'3':0,'4':0,'5':0,'6':0,'7':0,'8':0,'9':0,'10':0,
             '11':0,'12':0,'13':0,'14':0,'15':0,'16':0,'17':0,'18':0,'19':0}
n=1
sumP=0
for data in wD['CH1Avg']:           #70m高度的风速区间频率
    if data<0.5:
        vFreq['<0.5']+=1
        pFreq['<0.5']+=1/2*den*data**3
    if data>=0.5 and data<1.5:
        vFreq['1']+=1
        pFreq['1']+=1/2*den*data**3
    if data>=1.5 and data<2.5:
        vFreq['2']+=1
        pFreq['2']+=1/2*den*data**3
    if data>=2.5 and data<3.5:
        vFreq['3']+=1
        pFreq['3']+=1/2*den*data**3
    if data>=3.5 and data<4.5:
        vFreq['4']+=1
        pFreq['4']+=1/2*den*data**3
    if data>=4.5 and data<5.5:
        vFreq['5']+=1
        pFreq['5']+=1/2*den*data**3
    if data>=5.5 and data<6.5:
        vFreq['6']+=1
        pFreq['6']+=1/2*den*data**3
    if data>=6.5 and data<7.5:
        vFreq['7']+=1
        pFreq['7']+=1/2*den*data**3
    if data>=7.5 and data<8.5:
        vFreq['8']+=1
        pFreq['8']+=1/2*den*data**3
    if data>=8.5 and data<9.5:
        vFreq['9']+=1
        pFreq['9']+=1/2*den*data**3
    if data>=9.5 and data<10.5:
        vFreq['10']+=1
        pFreq['10']+=1/2*den*data**3
    if data>=10.5 and data<11.5:
        vFreq['11']+=1
        pFreq['11']+=1/2*den*data**3
    if data>=11.5 and data<12.5:
        vFreq['12']+=1
        pFreq['12']+=1/2*den*data**3
    if data>=12.5 and data<13.5:
        vFreq['13']+=1
        pFreq['13']+=1/2*den*data**3
    if data>=13.5 and data<14.5:
        vFreq['14']+=1
        pFreq['14']+=1/2*den*data**3
    if data>=14.5 and data<15.5:
        vFreq['15']+=1
        pFreq['15']+=1/2*den*data**3
    if data>=15.5 and data<16.5:
        vFreq['16']+=1
        pFreq['16']+=1/2*den*data**3
    if data>=16.5 and data<17.5:
        vFreq['17']+=1
        pFreq['17']+=1/2*den*data**3
    if data>=17.5 and data<18.5:
        vFreq['18']+=1
        pFreq['18']+=1/2*den*data**3
    if data>=18.5 and data<19.5:
        vFreq['19']+=1
        pFreq['19']+=1/2*den*data**3
    n+=1
    sumP+=1/2*den*data**3


for key in vFreq:
    vFreq[key]=format(vFreq[key]/n,'.5f')
print(vFreq)


for key in pFreq:
    pFreq[key]=format(pFreq[key]/sumP,'.5f')
print(pFreq)



